package com.kuang.springcloud.controller;

import org.springframework.beans.factory.annotation.Value;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.cloud.context.config.annotation.RefreshScope;
@RestController
//@RefreshScope
public class ConfigController {

    @Value(value = "${config.info}")
    private String configInfo;
    @Value("${config.version}")
    private Integer version;
    @RequestMapping("/config/info")
    @ResponseBody
    private String getConfigInfo(){
        System.out.println("configInfo = " + configInfo);
        if (configInfo == null) {
            return "configInfo 为 null";
        }
        return configInfo;
    }
    @GetMapping("/config/version")
    private Integer getVersion(){

        if (version == null) {
            return 0;
        }
        return version;
    }
}
